require("iterpath")
require("encoder")
require"pack"

local rootdir = lfs.currentdir()..'/../..'
iterPath(rootdir..'/src/login_gate/proto')


-- print(package.path)
require("login_pb")
require("socket")

function buildMsgBuffer(serverType, gateID, gsID, moduleID, msgID, msg)
	return string.pack(">HbbHHHiA", 0xDDEE, serverType, gateID, gsID, moduleID, msgID, login:ByteSize(), login:SerializeToString());
end

login = login_pb.Login()
login.name="test"
login.id = 1

server = assert(socket.connect("localhost", 5555))
print("connection....");

while true do
	a=io.read("*number")
	print(a)

	if a == 1 then
		server:send(buildMsgBuffer(1, 0, 0, 1, 1, login))
	end
end

